﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:music="clr-namespace:WickedSick.ClientComponents.Music;assembly=WickedSick.ClientComponents.Music"
    xmlns:local="clr-namespace:SDB"
    x:Class="SDB.SongDisplay"
    Title="SongDisplay" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
    <Window.Resources>
        <local:MediaValueConverter x:Key="mediaConverter" />
        <local:SongItemStyleSelector x:Key="SongItemStyleSelector"/>
        <Style x:Key="ShadowedTextBlock" TargetType="{x:Type Label}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Label}">
                        <Grid>
                            <TextBlock SnapsToDevicePixels="True" Margin="4, 4, 3, 3" FontFamily="{TemplateBinding FontFamily}" FontWeight="Bold" FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" Text="{TemplateBinding Content}"/>
                            <TextBlock SnapsToDevicePixels="True" Margin="3" FontFamily="{TemplateBinding FontFamily}" FontWeight="Bold" FontSize="{TemplateBinding FontSize}" Foreground="#FF576C8B" Text="{TemplateBinding Content}"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <HierarchicalDataTemplate DataType="{x:Type music:Artist}" ItemsSource="{Binding Path=Albums.Values}">
            <Label Style="{StaticResource ShadowedTextBlock}" Content="{Binding Name}" 
                   FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA" />
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate DataType="{x:Type music:Album}" ItemsSource="{Binding Path=Songs.Values}">
            <StackPanel>
                <Image Margin="8" HorizontalAlignment="Left" Source="D:\Personal\mp3s\AlbumArt_{0B6BE3A3-9D5D-488B-8802-69C8D696E85F}_Small.jpg">
                    <Image.BitmapEffect>
                        <DropShadowBitmapEffect />
                    </Image.BitmapEffect>
                </Image>
                <Label Margin="8, 0, 0, 0" Style="{StaticResource ShadowedTextBlock}" Content="{Binding Name}" 
                           FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA" />
                <Label Margin="8, 0, 0, 0" Style="{StaticResource ShadowedTextBlock}" 
                       FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA"
                       Content="{Binding Path=ReleaseDate, Converter={StaticResource mediaConverter}, ConverterParameter=ReleaseDate}" />
                <Label Margin="8, 0, 0, 0" Style="{StaticResource ShadowedTextBlock}" 
                       FontFamily="Segoe" FontSize="14" Foreground="#FFDCE1EA"
                       Content="{Binding Path=Songs.Count, Converter={StaticResource mediaConverter}, ConverterParameter=AlbumSongCount}" />
            </StackPanel>
        </HierarchicalDataTemplate>
        <DataTemplate DataType="{x:Type music:Song}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Image Source="images\0119.ico" Width="16" Height="16" Margin="2, 2, 5, 2"/>
                <TextBlock Grid.Column="1" SnapsToDevicePixels="True" Margin="4, 4, 3, 3" FontFamily="Segoe" FontSize="14" Foreground="#FF6A7699">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource mediaConverter}" ConverterParameter="TrackNumberTitle">
                            <Binding Path="TrackNumber" />
                            <Binding Path="Title" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <TextBlock Grid.Column="1" SnapsToDevicePixels="True" Margin="3" FontFamily="Segoe" FontSize="14" Foreground="White">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource mediaConverter}" ConverterParameter="TrackNumberTitle">
                            <Binding Path="TrackNumber" />
                            <Binding Path="Title" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            </Grid>
        </DataTemplate>
        <Style x:Key="ArtistStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Border BorderBrush="#FF576C8B" BorderThickness="1, 1, 1, 0">
                            <StackPanel>
                                <Border CornerRadius="3">
                                    <Border.Background>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFDCE1EA" Offset="0"/>
                                            <GradientStop Color="#FFAFBCCD" Offset="1"/>
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <Grid>
                                        <ContentPresenter x:Name="PART_Header" ContentSource="Header" Margin="10, 0, 10, 0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                                    </Grid>
                                </Border>
                                <Border Background="#FF576C8B">
                                    <Grid x:Name="ItemsHost">
                                        <ItemsPresenter HorizontalAlignment="Stretch"/>
                                    </Grid>
                                </Border>
                            </StackPanel>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Width" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinWidth" Value="75"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Height" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinHeight" Value="19"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="AlbumStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Border Margin="150, 0, 20, 0" BorderBrush="#33BFC5D4" BorderThickness="0, 1, 0, 0">
                            <Border BorderBrush="#FF8088A6" BorderThickness="0, 0, 1, 0" Background="#FFDCE1EA">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Top"/>
                                    <ItemsPresenter x:Name="ItemsHost" Grid.Column="1"/>
                                </Grid>
                            </Border>
                        </Border>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Width" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinWidth" Value="75"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Height" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinHeight" Value="19"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="25"/>
            <RowDefinition Height="25"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Button Grid.Row="0" Click="Button_Click" Content="DataBind"/>
        <TextBox Grid.Column="1" Text="{Binding Path=SelectedValue, ElementName=SongTree, Mode=OneWay}"/>
        <TextBox x:Name="ArtistFilter" Grid.Row="1" TextChanged="TextBox_TextChanged"/>
        <TreeView x:Name="SongTree" Grid.Row="2" Grid.ColumnSpan="3" BorderThickness="0" Padding="8" Background="#FF576C8B"
                  SnapsToDevicePixels="True" HorizontalContentAlignment="Stretch" 
                  ItemContainerStyleSelector="{StaticResource SongItemStyleSelector}"/>
    </Grid>
</Window>
